
package com.caration.shell;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Handler;
import android.os.HandlerThread;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class ShellModel extends BroadcastReceiver {

    private static final HandlerThread mLoadHandler = new HandlerThread("launcher-loader");
    private static Handler mHandler;
    private static boolean isReady = false;
//    final ArrayList a = new ArrayList();
//    final ArrayList b = new ArrayList();
//    final ArrayList c = new ArrayList();
//    final ArrayList d = new ArrayList();
//    final ArrayList e = new ArrayList();
    private int f;
    private int g;
    private final ShellApplication mApplication;
    private final Object i = new Object();
//    private j j;
//    private bg k;
//    private boolean l;
    private WeakReference m;
//    private a n;
//    private String o = "";
//
    ShellModel(ShellApplication application) {
        mApplication = application;
//        this.n = new a();
        this.g = application.getResources().getInteger(R.integer.config_allAppsBatchLoadDelay);
        this.f = application.getResources().getInteger(R.integer.config_allAppsBatchSize);
    }

    public static void init() {
        if (!isReady) {
            isReady = true;
            mLoadHandler.start();
            mHandler = new Handler(mLoadHandler.getLooper());
        }
    }

    public static void postRunnable(Runnable runnable) {
        if (mHandler != null)
            mHandler.post(runnable);
    }

    public final ArrayList a(Context paramContext) {
//        int i1 = 0;
//        System.currentTimeMillis();
//        Intent localIntent = new Intent("com.tsf.shell.themes", null);
//        List localList = paramContext.getPackageManager().queryIntentActivities(localIntent, 0);
//        Collections.sort(localList,
//                new ResolveInfo.DisplayNameComparator(paramContext.getPackageManager()));
//        int i2 = localList.size();
//        Object localObject1 = paramContext.getPackageManager();
//        Object localObject2 = new Intent("android.intent.action.MAIN", null);
//        ((Intent) localObject2).addCategory("android.intent.category.LAUNCHER");
//        ((Intent) localObject2).setPackage("com.tsf.shell");
//        localObject1 = ((PackageManager) localObject1).queryIntentActivities((Intent) localObject2,
//                0).iterator();
//        while (((Iterator) localObject1).hasNext()) {
//            localObject2 = (ResolveInfo) ((Iterator) localObject1).next();
//            this.n.c(new k((ResolveInfo) localObject2));
//        }
//        while (i1 < i2) {
//            localObject1 = (ResolveInfo) localList.get(i1);
//            if (!((ResolveInfo) localObject1).activityInfo.packageName
//                    .equals("com.tsf.shell.themes.box"))
//                this.n.c(new k((ResolveInfo) localObject1));
//            i1++;
//        }
//        ArrayList localArrayList = this.n.j;
//        this.n.j = new ArrayList();
//        return (ArrayList) (ArrayList) localArrayList;
    	return null;
    }
//
//    public final void a(Context paramContext, boolean paramBoolean) {
//        synchronized (this.i) {
//            if ((this.m != null) && (this.m.get() != null)) {
//                bg localbg = this.k;
//                if (localbg != null) {
//                    if (localbg.a())
//                        paramBoolean = true;
//                    localbg.b();
//                }
//                this.k = new bg(this, paramContext, paramBoolean);
//                mHandler.post(this.k);
//            }
//            return;
//        }
//    }
//
//    public final void a(ba paramba) {
//        synchronized (this.i) {
//            this.j = j.a();
//            this.m = new WeakReference(paramba);
//            return;
//        }
//    }
//
//    public final void b() {
//        synchronized (this.i) {
//            if (this.k != null)
//                this.k.b();
//            return;
//        }
//    }
//
    public void onReceive(Context paramContext, Intent paramIntent) {
//        Object localObject = paramIntent.getAction();
//        if ((!"android.intent.action.PACKAGE_CHANGED".equals(localObject))
//                && (!"android.intent.action.PACKAGE_REMOVED".equals(localObject))
//                && (!"android.intent.action.PACKAGE_ADDED".equals(localObject))) {
//            if (!"android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE".equals(localObject)) {
//                if ("android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE".equals(localObject))
//                    a(new bt(
//                            this,
//                            4,
//                            paramIntent
//                                    .getStringArrayExtra("android.intent.extra.changed_package_list")));
//            } else
//                a(new bt(this, 5,
//                        paramIntent
//                                .getStringArrayExtra("android.intent.extra.changed_package_list")));
//        } else {
//            String str = paramIntent.getData().getSchemeSpecificPart();
//            boolean bool = paramIntent.getBooleanExtra("android.intent.extra.REPLACING", false);
//            if ((str != null) && (str.length() != 0)) {
//                if (!"android.intent.action.PACKAGE_CHANGED".equals(localObject)) {
//                    if ("android.intent.action.PACKAGE_REMOVED".equals(localObject))
//                        break label184;
//                    if (!"android.intent.action.PACKAGE_ADDED".equals(localObject))
//                        break label189;
//                    if (!bool)
//                        ;
//                } else {
//                    i1 = 2;
//                    break label198;
//                }
//                int i1 = 1;
//                break label198;
//                label184: if (i1 != 0)
//                    label189: i1 = 0;
//                else
//                    i1 = 3;
//                label198: if (i1 != 0) {
//                    localObject = new String[1];
//                    localObject[0] = str;
//                    a(new bt(this, i1, localObject));
//                }
//            }
//        }
    }
}
